*===============================================================================
* Do-file creates "Experimental Dataset: Treatment Effects by Violence Expectations"
* Table A9
*===============================================================================
clear
set more off


cd "~/Dropbox/VFD/REStat_Native_Files/Stata_Files"
local output "~/Dropbox/VFD/REStat_Native_Files/Stata_Files/Output"

use cadg_master_NATIVE.dta, clear

*** Creating Dummies for Violence Survey Responses ***
gen v0 = (insurgentviolence==0) if insurgentviolence!=.
gen v1 = (insurgentviolence==1) if insurgentviolence!=.
gen v2 = (insurgentviolence==2) if insurgentviolence!=.
gen v3 = (insurgentviolence==3) if insurgentviolence!=.
gen v4 = (insurgentviolence==4) if insurgentviolence!=.
label var v0 "Violence Extremely Unlikely"
label var v1 "Violence Not Very Likely"
label var v2 "Violence Somewhat Likely"
label var v3 "Violence Very Likely"
label var v4 "Violence Extremely Likely"

gen t0_v0 = treat_final*v0
gen t0_v1 = treat_final*v1
gen t0_v2 = treat_final*v2
gen t0_v3 = treat_final*v3
gen t0_v4 = treat_final*v4
label var t0_v0 "Mobile Salary Treatment x Extremely Unlikely"
label var t0_v1 "Mobile Salary Treatment x Not Very Likely"
label var t0_v2 "Mobile Salary Treatment x Somewhat Likely"
label var t0_v3 "Mobile Salary Treatment x Very Likely"
label var t0_v4 "Mobile Salary Treatment x Extremely Likely"

gen t_v0 = treat_post*v0
gen t_v1 = treat_post*v1
gen t_v2 = treat_post*v2
gen t_v3 = treat_post*v3
gen t_v4 = treat_post*v4
label var t_v0 "Mobile Salary Treatment x Post x Extremely Unlikely"
label var t_v1 "Mobile Salary Treatment x Post x Not Very Likely"
label var t_v2 "Mobile Salary Treatment x Post x Somewhat Likely"
label var t_v3 "Mobile Salary Treatment x Post x Very Likely"
label var t_v4 "Mobile Salary Treatment x Post x Extremely Likely"

gen post_v0 = post*v0
gen post_v1 = post*v1
gen post_v2 = post*v2
gen post_v3 = post*v3
gen post_v4 = post*v4
label var post_v0 "Mobile Salary Treatment x Extremely Unlikely"
label var post_v1 "Mobile Salary Treatment x Not Very Likely"
label var post_v2 "Mobile Salary Treatment x Somewhat Likely"
label var post_v3 "Mobile Salary Treatment x Very Likely"
label var post_v4 "Mobile Salary Treatment x Extremely Likely"


* Column 1
xi: reg cumbalance treat_post t_v0 t_v1 t_v3 t_v4 treat_final post post_v0 post_v1 post_v3 post_v4 t0_v0 t0_v1 t0_v3 t0_v4 v0 v1 v3 v4 i.ym if sample_cash_outlier==0, cl(employeenumber) 
est store col1
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"

* Column 2
xi: reg cumbalance treat_post t_v0 t_v1 t_v3 t_v4 treat_final post post_v0 post_v1 post_v3 post_v4 t0_v0 t0_v1 t0_v3 t0_v4 v0 v1 v3 v4 i.ym i.province i.block_final if sample_cash_outlier==0, cl(employeenumber) 
est store col2
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"

* Column 3
xi: xtreg cumbalance treat_post t_v0 t_v1 t_v3 t_v4 treat_final post post_v0 post_v1 post_v3 post_v4 t0_v0 t0_v1 t0_v3 t0_v4 v0 v1 v3 v4 i.ym if sample_cash_outlier==0, cl(employeenumber) fe i(employeenumber)
est store col3
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"

* Export to Latex
esttab col1 col2 col3 using "`output'/table_a9.tex", cells(b(fmt(%9.2f) star) se(par fmt(%9.2f))) ///
starlevels(* .1 ** .05 *** .01) style(tex) keep(treat_post t_v0 t_v1 t_v3 t_v4 v0 v1 v3 v4) ///
stats(samplestr in_sample_mean N_clust N r2 monthFE stratumFE individFE, fmt(0 2 0 0 2 0 0 0) label("Sample" "Mean Dep Var" "\# Employees" "\# Observations" "R-Squared" "Month FE" "Strata FE" "Employee FE")) ///
label title("Treatment Effects by Violence Expectations") replace














